/*
 * Copyright Iain Sproat, 2009
 * 
 *
 */
using System;
using System.Collections.Generic;

namespace FreeBase.Domain
{
	/// <summary>
	/// This is the equivalent of freebase's /type/type
	/// </summary>
	public class FBType
	{
		public FBType()
		{
		}
		
		public FBText Name{ get; set; }
		public IList<FBProperty> Properties{ get; set; }
		public IList<FBObject> Instance{ get; set; }
		public FBDomain Domain{ get; set; }
		public IList<FBProperty> ExpectedBy{ get; set; }
		public FBText DefaultProperty{ get; set; }
		public FBType Extends{ get; set; }
		
		public static implicit operator FBType( string name )
		{
			FBType t = new FBType();
			t.Name =  name;
			return t;
		}
		
		public override bool Equals(object obj)
		{
			if( obj == null )
				return false;
			FBType t = obj as FBType;
			if( t == null )
				return false;
			return t.Name == this.Name; //TODO expand for other properties
		}
		
		public static bool operator ==(FBType lhs, object rhs )
		{
			return lhs.Equals( rhs );
		}
		public static bool operator !=(FBType lhs, object rhs )
		{
			return !lhs.Equals( rhs );
		}
		
		public override int GetHashCode()
		{
			return this.Name.GetHashCode(); //TODO expand for other properties
		}
	}
}
